package top.ljlgithub.api.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import top.ljlgithub.api.bean.Report;
import top.ljlgithub.api.common.response.Meta;
import top.ljlgithub.api.common.response.ResponseEntity;
import top.ljlgithub.api.service.ReportService;

import java.util.HashMap;

/**
 * @ClassName
 * @Description TODO
 * @Author L1470
 * @Date 2021/5/7 18:28
 * @Version 1.0
 **/
@RestController
@CrossOrigin
public class ReportController {
    @Autowired
    ReportService reportService;
    @GetMapping("/reports/type/1")
    public ResponseEntity getReport(){
        Meta meta = new Meta("获取报表成功", 200);
        Report report = reportService.getReport();
        HashMap<String, Object> data = new HashMap<>();
        data.put("legend",report.getLegend());
        data.put("yAxis",report.getYAxis());
        data.put("xAxis",report.getXAxis());
        data.put("series",report.getSeries());
        ResponseEntity<Object> result = new ResponseEntity<>(data,meta);
        return result;
    }
}
